function e(e) {
    return function() {
        var t = e.apply(this, arguments);
        return new Promise(function(e, n) {
            function r(o, a) {
                try {
                    var u = t[o](a), i = u.value;
                } catch (e) {
                    return void n(e);
                }
                if (!u.done) return Promise.resolve(i).then(function(e) {
                    r("next", e);
                }, function(e) {
                    r("throw", e);
                });
                e(i);
            }
            return r("next");
        });
    };
}

var t = require("../../utils/api.js"), n = require("../../utils/config.js"), r = (require("../../utils/util.js"), 
function(e) {
    return e && e.__esModule ? e : {
        default: e
    };
}(require("../../utils/wxPromise.min.js")));

getApp();

Page({
    data: function(e, t, n) {
        return t in e ? Object.defineProperty(e, t, {
            value: n,
            enumerable: !0,
            configurable: !0,
            writable: !0
        }) : e[t] = n, e;
    }({
        visible: !1,
        DEFAULTHOMEGIF: n.DEFAULTHOMEGIF,
        DEFAULTBGIMAGE: n.DEFAULTBGIMAGE,
        code: null,
        groupInfo: {},
        homeConfig: {},
        status: "loading"
    }, "code", null),
    start: function() {
        var e = this;
        if (console.log(this.data), this.data.code) return wx.navigateTo({
            url: "/pages/make/make?code=" + this.data.code + "&max_duration=" + (this.data.groupInfo.audio_max_duration || 60)
        });
        wx.pro.scanCode({
            scanType: "qrCode"
        }).catch(function(e) {
            if (-1 !== e.errMsg.indexOf("cancel")) throw e;
            throw wx.showModal({
                content: "二维码扫描失败",
                showCancel: !1
            }), e;
        }).then(function(t) {
            return e.init(t.result);
        }).then(function() {
            var e = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {}, t = e.codeInfo, n = e.groupInfo;
            if (t && n) return wx.navigateTo({
                url: "/pages/make/make?code=" + t.code + "&max_duration=" + (n.audio_max_duration || 60)
            });
        });
    },
    onLoad: function(n) {
        var o = this;
        return e(r.default.mark(function e() {
            var a, u, i, s, c;
            return r.default.wrap(function(e) {
                for (;;) switch (e.prev = e.next) {
                  case 0:
                    return wx.hideShareMenu(), console.log("options", n), a = null, u = null, n.q && (i = decodeURIComponent(n.q), 
                    o.init(i)), e.next = 7, (0, t.getHomeConfig)();

                  case 7:
                    s = e.sent, c = s.data, o.setData({
                        homeConfig: c,
                        visible: !0
                    });

                  case 10:
                  case "end":
                    return e.stop();
                }
            }, e, o);
        }))();
    },
    init: function(n) {
        var o = this;
        arguments.length > 1 && void 0 !== arguments[1] && arguments[1];
        return e(r.default.mark(function e() {
            var a, u, i, s;
            return r.default.wrap(function(e) {
                for (;;) switch (e.prev = e.next) {
                  case 0:
                    return a = n.split("/").pop(), e.next = 3, (0, t.getQrcode)(a);

                  case 3:
                    if (u = e.sent, i = u.data, s = (0, t.getGroupConfig)(a), 2 !== i.status) {
                        e.next = 8;
                        break;
                    }
                    return e.abrupt("return", wx.pro.redirectTo({
                        url: "/pages/view/view?url=" + n
                    }));

                  case 8:
                    if (i.status) {
                        e.next = 10;
                        break;
                    }
                    return e.abrupt("return", wx.pro.showModal({
                        content: "请扫描正确的传声码",
                        showCancel: !1
                    }));

                  case 10:
                    return 1 === i.status && o.setData({
                        code: a
                    }), e.abrupt("return", s.then(function(e) {
                        var t = e.data;
                        return o.setData({
                            groupInfo: t
                        }), {
                            codeInfo: i,
                            groupInfo: t
                        };
                    }));

                  case 12:
                  case "end":
                    return e.stop();
                }
            }, e, o);
        }))();
    }
});